<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-operator" style="border-top: 5px">
          <a-button   @click="handleAdd" type="primary" icon="plus">新增</a-button>
        </div>
        <div>
          <a-table
            ref="table"
            bordered
            size="middle"
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange">
            <span slot="action" slot-scope="text, record">
              <a @click="myHandleDetail(record)">详情</a>
              <a-divider type="vertical" />
                <a @click="handleEdit(record)">编辑</a>
              <a-divider  v-if="btnEnableList.indexOf(6)>-1"  type="vertical"/>
              <a  v-if="btnEnableList.indexOf(6)>-1"  @click="handleProduce(record)">下单</a>
              <a-divider  v-if="btnEnableList.indexOf(4)>-1"  type="vertical" />
              <a-popconfirm  v-if="btnEnableList.indexOf(4)>-1" title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
           
            </span>
            <!-- 状态渲染模板 -->
            <template slot="customRenderFlag" slot-scope="status">
              <a-tag v-if="status===0" color="green">启用</a-tag>
              <a-tag v-if="status===2" color="orange">禁用</a-tag>
            </template>
          </a-table>
        </div>
        <!-- table区域-end -->
        <BusinessConfigOpeListManageModal ref="modalForm" @ok="modalFormOk"></BusinessConfigOpeListManageModal>
        <BusinessConfigOpeListDetail ref="BusinessConfigOpeListDetail"></BusinessConfigOpeListDetail>
      </a-card>
    </a-col>
  </a-row>
</template>

<script>
  import BusinessConfigOpeListManageModal from './modules/BusinessConfigOpeListManageModal'
  import BusinessConfigOpeListDetail from './dialog/BusinessConfigOpeListDetail'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  export default {
    name: "/CustomList",
    mixins: [JeecgListMixin],
    components: {
      BusinessConfigOpeListManageModal,
      BusinessConfigOpeListDetail,
      JInput
    },
    data() {
      return {
        labelCol: {
          span: 5
        },
        wrapperCol: {
          span: 18,
          offset: 1
        },
        queryParam: {},
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:40,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          { title: '业务员', dataIndex: 'name', width: 100, align: "center"},
          { title: '联系电话', dataIndex: 'tel', width: 140, align: "center"},
          { title: '身份证号码', dataIndex: 'idNumber', width: 140, align: "center" },
          { title: '创建用户', dataIndex: 'createUserStr', width: 80, align: "center"},
          { title: '创建时间', dataIndex: 'createTimeStr', width: 120, align: "center"},
          // { title: '修改用户', dataIndex: 'updateUser', width: 80, align: "center"},
          { title: '修改时间', dataIndex: 'updateTimeStr', width: 120, align: "center"},
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: {customRender: 'action'},
            align: "center",
            width: 220
          }
        ],
        url: {
          // 列表请求
          list: "/configOperator/list",
          delete: "/configOperator/delete"
        },
      }
    },

    methods: {
      myHandleDetail(record) {
        this.$refs.BusinessConfigOpeListDetail.show(record);
        this.$refs.BusinessConfigOpeListDetail.title="详情";
      },
      searchQuery() {
        this.loadData(1);
      },
      searchReset() {
        this.queryParam = {}
        this.loadData(1);
      },

      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "编辑";
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)>-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      },
      handleInfo: function (record) {
        this.$refs.engineerInfoModal.edit(record);
        this.$refs.engineerInfoModal.title = "工程查看";
        this.$refs.engineerInfoModal.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.engineerInfoModal.isReadOnly = true
        }
      },
      handleSupply: function(record) {
        this.$refs.engineerSupplyModal.add(record);
        this.$refs.engineerSupplyModal.title = "工程补充";
        this.$refs.engineerSupplyModal.disableSubmit = false;
      },
      handleProduce: function(record) {
        this.$refs.engineerProduceModal.add(record);
        this.$refs.engineerProduceModal.title = "产品下单";
        this.$refs.engineerProduceModal.disableSubmit = false;
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>